SMTP Troubleshooting And Error Handling
This document provides comprehensive troubleshooting guidance for SMTP integration issues within the application. It explains common error scenarios, diagnostic steps for network and provider-specific problems, and practical resolutions. It also covers log analysis, SSL/TLS certificate handling, and performance optimization strategies such as connection verification, rate limiting, and progress reporting.
The application integrates SMTP email sending through Electron’s main process and a React UI. The Electron main process exposes IPC handlers for email operations, while the renderer invokes them securely via a preload bridge. SMTP operations are handled by a dedicated handler that validates configuration, verifies connectivity, and sends emails with progress updates.
BulkMailer.jsx, SMTPForm.jsx"] --> Preload["Preload Bridge
preload.js"] Preload --> Main["Electron Main
main.js"] Main --> SMTPHandler["SMTP Handler
smtp-handler.js"] SMTPHandler --> Nodemailer["Nodemailer Transport"] Main --> GmailHandler["Gmail Handler
gmail-handler.js"]
Diagram sources
Section sources
Electron main process IPC handlers for SMTP and Gmail
Preload bridge exposing secure IPC methods
SMTP handler performing configuration validation, connection verification, and per-recipient sending with progress events
UI components for SMTP configuration, recipient import, and real-time activity logging
Key implementation references:
SMTP send handler and transport creation
Connection verification and per-email sending loop
Progress events emitted to the renderer
UI form validation and submission flow
Section sources
The SMTP workflow is initiated from the UI, routed through the preload bridge, executed in the main process, and emits progress events back to the UI for display.
Diagram sources
SMTP Handler: Configuration, Verification, and Delivery#
The SMTP handler performs:
Configuration validation (host, port, user, pass)
Optional credential saving (encrypted storage)
Transport creation with TLS options
Connection verification
Per-recipient email sending with progress events
Error handling and result aggregation
Diagram sources
Section sources
UI Integration: Form Validation and Progress Logging#
The UI validates inputs, constructs the SMTP payload, and listens for progress events to render real-time status.
Diagram sources
Section sources
Electron main process registers IPC handlers for SMTP and Gmail.
Preload exposes safe IPC methods to the renderer.
SMTP handler depends on Nodemailer for transport and on electron-store for optional credential persistence.
UI components depend on Electron APIs exposed via preload.
Diagram sources
Section sources
Connection verification: The handler calls a verification step before sending to detect misconfiguration early.
Rate limiting: A configurable delay is applied between emails to reduce the risk of throttling or rate limits.
Progress reporting: Real-time progress events allow users to monitor sending status and diagnose slow deliveries.
Recommendations:
Increase delay for providers with strict rate limits.
Batch recipients thoughtfully to avoid exceeding provider quotas.
Monitor progress events to identify intermittent failures and adjust timing.
Section sources
Common SMTP Errors and Meanings#
Authentication failure
Cause: Incorrect username/password or missing/invalid app-specific credentials.
Symptom: Immediate failure during authentication or initial connection verification.
Connection timeout
Cause: Network issues, firewall blocking, or incorrect port/security settings.
Symptom: Failure during verification or first send attempt.
TLS/SSL handshake failure
Cause: Mismatched security mode (port vs. secure flag), unsupported cipher, or self-signed certificate.
Symptom: Handshake errors or certificate warnings.
Certificate validation error
Cause: Untrusted CA, expired certificate, or hostname mismatch.
Symptom: Certificate-related error messages.
Delivery rejection
Cause: Spam filters, blocked sender, or recipient domain policy.
Symptom: SMTP response indicating rejection; often surfaced as a thrown error in the send operation.
Provider-specific notes:
Gmail SMTP typically requires App Passwords or OAuth2. The project supports Gmail API integration via OAuth2; for SMTP, ensure App Passwords are used when required.
Outlook SMTP commonly uses TLS on port 587; confirm security setting matches the port.
Section sources
Diagnostic Steps#
Verify SMTP configuration
Confirm host, port, user, and pass are provided and correct.
Match secure flag with the intended port (SSL/TLS).
Test connectivity
Use a command-line SMTP client or online SMTP tester to validate host/port/firewall.
Ensure outbound ports are open (commonly 587, 465).
Inspect DNS and MX records
Resolve the SMTP host and verify MX records for the sender domain.
Check firewall and proxy
Temporarily disable firewall or add exceptions for the app.
If behind a corporate proxy, configure proxy settings appropriately.
Validate certificates
For self-signed certificates, review TLS options and consider CA trust chain.
Ensure system clock is correct to avoid certificate expiry issues.
Section sources
Provider-Specific Troubleshooting#
Gmail
Use App Passwords or enable 2FA and generate an App Password.
Confirm TLS on port 587 or SSL on port 465.
Prefer OAuth2 for API-based sending when available.
Outlook/Hotmail
Use TLS on port 587.
Ensure account allows SMTP access and is not restricted by policies.
Yahoo
Use TLS on port 587.
Confirm SMTP access is enabled in account settings.
Section sources
Log Analysis and Debugging Approaches#
Enable verbose logging
Capture Electron main process logs and renderer logs during SMTP operations.
Use the progress events to correlate timestamps and statuses.
Inspect error messages
Errors thrown during sendMail or verification include actionable details.
UI activity log
The UI displays per-recipient status and error messages for quick diagnosis.
Section sources
Certificate Validation, SSL/TLS, and CA Issues#
TLS options
The handler sets TLS to reject unauthorized certificates by default; adjust only if necessary for self-signed environments.
Certificate authorities
Ensure system trust stores include the CA chain for the SMTP host.
Hostname verification
Mismatches cause certificate errors; verify the SMTP host matches the certificate.
Section sources
Solutions and Step-by-Step Resolution Guides#
Authentication Failures#
Verify credentials
Confirm username/email and password/app password are correct.
Enable less secure apps or use App Passwords (where applicable)
Some providers require App Passwords for SMTP access.
Check provider-specific requirements
Ensure two-factor authentication settings and app permissions are configured.
Section sources
Connection Timeouts#
Validate host and port
Confirm the SMTP host resolves and the port is reachable.
Check firewall and network
Temporarily disable firewall or whitelist the app.
Test with a known-good client
Use telnet or openssl s_client to test connectivity.
Section sources
TLS/SSL Handshake Failures#
Match security mode to port
Use SSL on port 465; TLS on port 587.
Update TLS options cautiously
Only modify TLS settings if dealing with self-signed certificates.
Update system trust store
Ensure intermediate CAs are installed.
Section sources
Certificate Authority Issues#
Verify certificate chain
Ensure the server presents a valid chain recognized by the OS.
Update trust store
Install missing intermediate certificates.
Consider temporary TLS adjustments (self-signed environments only)
Use TLS options carefully and revert afterward.
Section sources
Delivery Rejections#
Check recipient validity
Ensure recipient addresses are properly formatted.
Review provider policies
Exceeding rate limits or triggering spam filters causes rejections.
Use lower rate and monitor progress
Increase delays between emails to avoid throttling.
Section sources
Best Practices and Recommendations#
Always verify configuration before sending.
Use rate limiting to avoid throttling.
Monitor progress events to identify failing recipients quickly.
Prefer OAuth2 for Gmail API when possible.
Keep TLS settings aligned with provider requirements.
Section sources
This guide consolidates SMTP troubleshooting practices grounded in the application’s implementation. By validating configuration, verifying connections, aligning TLS settings with provider requirements, and monitoring progress events, most SMTP issues can be diagnosed and resolved efficiently. Adopt rate limiting and provider-specific configurations to maintain reliable delivery.